<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{path: '/manage'}">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item :to="{path: '/manage/userManage'}">用户列表</el-breadcrumb-item>
      <el-breadcrumb-item>用户详情</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="back" :body-style="{padding: '10px'}">
      <i class="el-icon-back" @click="goBack()">返回用户列表</i>
      <span>zzf经理</span>
    </el-card>
    <el-card :body-style="{padding: '10px'}" shadow="never">
      <div class="top">
        <ul>
          <li>
            <div class="img"><img src="../../assets/avatar.png" alt="" width="60" height="60"></div>
            <div class="msg">
              <p class="name">zzf经理</p>
              <p class="phone">手机号：1562565879</p>
            </div>
          </li>
          <li>
            <p class="title">到期时间</p>
            <p class="title_content">2019-12-09 23:59</p>
          </li>
          <li>
            <p class="title">剩余天数</p>
            <p class="title_content">323天</p>
          </li>
          <li>
            <p class="title">到期时间</p>
            <p class="title_content">2019-12-09 23:59</p>
          </li>
        </ul>
      </div>
      <div class="economics">
        <h3>经济概览</h3>
        <el-table
          :data="ecData"
          :stripe="true"
          :header-cell-style="rowClass"
          style="text-align: center;"
          size="small">
          <el-table-column
            label="订单总数">
            <template slot-scope="scope">
              <span>{{scope.row.ordersTotal}}单</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="moneyTotal"
            label="销售总额">
            <template slot-scope="scope">
              <span>{{scope.row.moneyTotal}}￥</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="userTotal"
            label="客户人员总数">
            <template slot-scope="scope">
              <span>{{scope.row.ordersTotal}}人</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="oneOrderMust"
            label="单笔最大订单">
            <template slot-scope="scope">
              <span>{{scope.row.ordersTotal}}￥</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="nav">
        <h3>用户记录</h3>
        <el-tabs type="border-card">
          <el-tab-pane :lazy="true">
            <span slot="label"><i class="el-icon-date"></i>订单总览</span>
            <orders-tab user-id-for-orders="1"/>
          </el-tab-pane>
          <el-tab-pane :lazy="true">
            <span slot="label"><i class="el-icon-date"></i>商品总览</span>
            <goods-tab user-id-for-goods="2"/>
          </el-tab-pane>
          <el-tab-pane :lazy="true">
            <span slot="label"><i class="el-icon-date"></i>分体客户总览</span>
            <staff-tab user-id-for-staff="3"/>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-card>
  </div>
</template>

<script>
import ordersTab from '../tabs/ordersTab'
import goodsTab from '../tabs/goodsTab'
import staffTab from '../tabs/staffTab'
export default {
  name: 'user-detail',
  data () {
    return {
      userId: '',
      ecData: [
        {
          ordersTotal: 151,
          moneyTotal: 16548,
          userTotal: 100,
          oneOrderMust: 10000
        }
      ]
    }
  },
  methods: {
    goBack () {
      this.$router.go(-1)
    },
    rowClass ({column, columnIndex}) {
      let style = {background: '#409EFF', color: '#fff', textAlign: 'center'}
      if (columnIndex === 0) {
        style.borderRadius = '6px 0 0 0'
      } else if (columnIndex === 3) {
        style.borderRadius = '0 6px 0 0'
      }
      return style
    }
  },
  created () {
    let params = this.$route.query
    if (!params.id) {
      this.$router.push('/manage/userManage')
    }
    this.userId = params.id
  },
  components: {
    ordersTab,
    goodsTab,
    staffTab
  }
}
</script>

<style scoped>
  h3{
    color: #303133;
    margin-bottom: 10px;
    margin-left: 5px;
  }
.back{
  color: #909399;
  margin-bottom: 15px;
}
  .back i{
    cursor: pointer;
    margin-right: 10px;
    font-size: 13px;
    font-weight: bold;
  }
  .back span{
    color: #606266;
    font-size: 15px;
    font-weight: 800;
  }
  .top{
    overflow: hidden;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
  }
  .top ul{
    overflow: hidden;
  }
  .top li{
    float: left;
    width: 25%;
    height: 100%;
    vertical-align: bottom;
    overflow: hidden;
  }
  .img{
    width: 60px;
    height: 60px;
    border-radius: 100%;
    overflow: hidden;
    float: left;
    margin-right: 10px;
  }
  .msg{
    float: left;
  }
  .msg .name{
    font-size: 18px;
    font-weight: 800;
    color: #303133;
    line-height: 35px;
  }
  .msg .phone{
    font-size: 12px;
    color: #606266;
    line-height: 25px;
  }
  .title{
    font-size: 12px;
    color: #606266;
    font-weight: bold;
    font-family: PingFang SC;
    line-height: 25px;
  }
  .title_content{
    font-size: 14px;
    color: #303133;
    line-height: 30px;
  }
  .economics{
    margin-top: 20px;
    margin-bottom: 20px;
  }
</style>
